//
//  YQStatus.m
//  WeiboOC
//
//  Created by yang on 15/11/18.
//  Copyright © 2015年 yang. All rights reserved.
//

#import "YQStatus.h"

@implementation YQStatus
+(instancetype)statusWithDict:(NSDictionary *)dict{
    YQStatus *s = [[self alloc]init];
    [s setValuesForKeysWithDictionary:dict];
    return s;
}
- (void)setValue:(id)value forKey:(NSString *)key{
    if ([key  isEqual: @"id"]) {
        self.ID = value;
        return;
    }
    if ([key isEqual:@"user"]) {
       self.user = [YQUser userWithDict:value];
        return;
    }
    if ([key isEqual:@"retweeted_status"]) {
        self.retweeted_status = [YQStatus statusWithDict:value];
        return;
    }
    [super setValue:value forKey:key];
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key{

}
//原创微博的图片的url
-(NSArray *)imageURLs{
    NSMutableArray *array = [NSMutableArray array];
    if (self.pic_urls) {
        for (NSDictionary *dict in self.pic_urls) {
            NSURL *url = [NSURL URLWithString:dict[@"thumbnail_pic"]];
            [array addObject:url];
        }
    }
    return array;
}
 //单张图片时返回的 URL
-(NSArray *)url{
    if (self.retweeted_status == nil) {
        return self.imageURLs;
    }
    return self.retweeted_status.imageURLs;
}
@end
